<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:html="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="html">
	<xsl:output method="xml" indent="yes" doctype-public="-//W3C//DTD XHTML 1.1//EN" doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" encoding="UTF-8"/>

	<xsl:template name="show_repetition">
		<xsl:param name="name"/>
		<xsl:choose>
		<xsl:when test="count(/document/contents/repetition[@name=$name])&gt;0">
		<xsl:for-each select="/document/contents/repetition[@name=$name]">
			<xsl:if test="/document/editmode='1'">
				<div style="margin:0px;padding:0px;background-color:#eeeeee;border:1px solid #000000;">
					<xsl:if test="position()=1">
						<xsl:call-template name="add_repetition">
							<xsl:with-param name="name" select="$name"/>
						</xsl:call-template>
					</xsl:if>
					<xsl:call-template name="del_repetition">
						<xsl:with-param name="id" select="./@id"/>
					</xsl:call-template>
					<xsl:call-template name="show_repetition_templates">
						<xsl:with-param name="repetitionid" select="./@id"/>
					</xsl:call-template>
				</div>
			</xsl:if>
			<xsl:call-template name="show_repetition_content">
				<xsl:with-param name="path" select="./@id"/>
			</xsl:call-template>
		</xsl:for-each>
		</xsl:when>
		<xsl:otherwise>
			<xsl:if test="/document/editmode='1'">
				<div style="margin:0px;padding:0px;background-color:#eeeeee;border:1px solid #000000;">
					<xsl:if test="position()=1">
						<xsl:call-template name="add_repetition">
							<xsl:with-param name="name" select="$name"/>
						</xsl:call-template>
					</xsl:if>
				</div>
			</xsl:if>
		</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="show_repetition_templates">
		<xsl:param name="repetitionid"/>
		<form method="post" action="{/document/filename}&amp;repetitionid={$repetitionid}" style="padding:0px; margin:0px; display:inline;font-size:10px;font-family:Arial,Verdana,sans-serif;">
			<select name="select_block_template">
				<option value=""><xsl:text disable-output-escaping="yes">--- Bitte w&amp;auml;hlen ---</xsl:text></option>
				<optgroup label="Textbloecke">
					<xsl:for-each select="/document/blocktemplates/block">
						<option value="{.}.xsl">
							<xsl:if test="//repetition[@id=$repetitionid]/@template=concat(.,'.xsl')">
								<xsl:attribute name="selected">selected</xsl:attribute>
							</xsl:if>
							<xsl:value-of select="translate(.,'_',' ')"/>
						</option>
					</xsl:for-each>
				</optgroup>
				<optgroup label="Module">
					<xsl:for-each select="/document/modules/modul">
						<option value="mod_{.}">
							<xsl:if test="//repetition[@id=$repetitionid]/@module=.">
								<xsl:attribute name="selected">selected</xsl:attribute>
							</xsl:if>
							<xsl:value-of select="translate(.,'_',' ')"/>
						</option>
					</xsl:for-each>
				</optgroup>
			</select>
			<input type="submit" value="Speichern"/>
		</form>
	</xsl:template>

	<xsl:template name="show_repetition_content">
		<xsl:param name="path"/>
		<xsl:for-each select="//repetition[@id=$path]">
			<xsl:value-of select="./rendered" disable-output-escaping="yes"/>
		</xsl:for-each>
	</xsl:template>

	<xsl:template name="add_repetition">
		<xsl:param name="name"/>
		<xsl:if test="/document/editmode='1'">
			<a href="{/document/filename}&amp;addrepetition={$name}">
				<img src="/images/plus.gif" border="0" width="16" height="16" alt="Wiederholung hinzufügen - {$name}" title="Wiederholung hinzufügen - {$name}"/>
			</a>
		</xsl:if>
	</xsl:template>

	<xsl:template name="del_repetition">
		<xsl:param name="id"/>
		<xsl:if test="/document/editmode='1'">
			<a href="javascript:askdelete('{/document/admin_url}{/document/filename}&amp;delrepetition={$id}')">
				<img src="/images/delete_small.gif" border="0" width="16" height="16" alt="Wiederholung löschen"/>
			</a>
		</xsl:if>
	</xsl:template>

	<xsl:template name="graphicfield">
		<xsl:param name="align" select="''"/>
		<xsl:param name="width" select="''"/>
		<xsl:param name="height" select="''"/>
		<xsl:param name="border" select="'0'"/>
		<xsl:param name="repetition" select="./@id"/>
		<xsl:param name="name"/>
		<xsl:param name="padding" select="'0px;'"/>
		<xsl:param name="margin" select="'0px;'"/>
		<xsl:choose>
			<xsl:when test="/document/editmode='1'">
				<script language="JavaScript" type="text/javascript">
				&lt;!--
					function opengraphicwindow<xsl:value-of select="concat(./@id,image[@name=$name]/@id)"/>() {
						window.open('admin_content_editgraphic.php?<xsl:value-of select="/document/filenamezusatz"/>&amp;editrepetition=<xsl:value-of select="$repetition"/>&amp;editimage=<xsl:value-of select="$name"/>','graphicwindow','width=500,height=400,scrollbars=yes');
					}
				// --&gt;
				</script>
				<a href="javascript:opengraphicwindow{concat(./@id,image[@name=$name]/@id)}()">
					<img src="/images/edit.gif" border="0" width="16" height="16" alt="Feld bearbeiten">
						<xsl:if test="$align!=''">
							<xsl:attribute name="align"><xsl:value-of select="$align"/></xsl:attribute>
						</xsl:if>
					</img>
				</a>
			</xsl:when>
		</xsl:choose>
		<xsl:choose>
			<xsl:when test="image[@name=$name]/@link!=''">
				<a href="link://{image[@name=$name]/@link}">
					<xsl:call-template name="show_graphicfieldimage">
						<xsl:with-param name="align" select="$align"/>
						<xsl:with-param name="width" select="$width"/>
						<xsl:with-param name="height" select="$height"/>
						<xsl:with-param name="padding" select="$padding"/>
						<xsl:with-param name="border" select="$border"/>
						<xsl:with-param name="margin" select="$margin"/>
						<xsl:with-param name="image" select="image[@name=$name]"/>
					</xsl:call-template>
				</a>
			</xsl:when>
			<xsl:otherwise>
				<xsl:call-template name="show_graphicfieldimage">
					<xsl:with-param name="align" select="$align"/>
					<xsl:with-param name="width" select="$width"/>
					<xsl:with-param name="height" select="$height"/>
					<xsl:with-param name="padding" select="$padding"/>
					<xsl:with-param name="border" select="$border"/>
					<xsl:with-param name="margin" select="$margin"/>
					<xsl:with-param name="image" select="image[@name=$name]"/>
				</xsl:call-template>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template name="show_graphicfieldimage">
		<xsl:param name="align" select="''"/>
		<xsl:param name="width" select="''"/>
		<xsl:param name="height" select="''"/>
		<xsl:param name="border" select="'0'"/>
		<xsl:param name="padding" select="'0px;'"/>
		<xsl:param name="margin" select="'0px;'"/>
		<xsl:param name="image" select="'0px;'"/>
		<img src="image://{$image}">
			<xsl:if test="$width!=''">
				<xsl:attribute name="width"><xsl:value-of select="$width"/></xsl:attribute>
			</xsl:if>
			<xsl:if test="$height!=''">
				<xsl:attribute name="height"><xsl:value-of select="$height"/></xsl:attribute>
			</xsl:if>
			<xsl:if test="$align!=''">
				<xsl:attribute name="align"><xsl:value-of select="$align"/></xsl:attribute>
			</xsl:if>
			<xsl:if test="$border!=''">
				<xsl:attribute name="border"><xsl:value-of select="$border"/></xsl:attribute>
			</xsl:if>
		</img>
	</xsl:template>

	<xsl:template name="editfield">
		<xsl:param name="repetition" select="./@id"/>
		<xsl:param name="name"/>
		<xsl:param name="css" select="'p'"/>
		<xsl:param name="bgcolor" select="'#ffffff'"/>
		<xsl:choose>
			<xsl:when test="block[@name=$name]/@edit='1'">
				<xsl:call-template name="rtffield">
					<xsl:with-param name="name" select="$name"/>
					<xsl:with-param name="css" select="$css"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<xsl:choose>
					<xsl:when test="/document/editmode='1'">
						<script language="JavaScript" type="text/javascript">
						&lt;!--
							function openeditwindow<xsl:value-of select="concat(./@id,block[@name=$name]/@id)"/>() {
								window.open('admin_content_editfield.php?<xsl:value-of select="/document/filenamezusatz"/>&amp;editrepetition=<xsl:value-of select="$repetition"/>&amp;editblock=<xsl:value-of select="$name"/>','editwindow','width=500,height=400,scrollbars=yes');
							}
						// --&gt;
						</script>
						<a href="javascript:openeditwindow{concat(./@id,block[@name=$name]/@id)}()">
							<img src="/images/edit.gif" border="0" width="16" height="16" alt="Feld bearbeiten"/>
						</a>
					</xsl:when>
				</xsl:choose>
				<xsl:value-of select="block[@name=$name]" disable-output-escaping="yes"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="rtffield">
		<xsl:param name="name"/>
		<xsl:param name="css"/>
		<xsl:param name="bgcolor"/>
		<a name="{$name}">
			<xsl:text> </xsl:text>
		</a>
		<form action="{/document/filename}" method="post" onsubmit="return submitForm();">
			<input type="hidden" name="edittextblock" value="{block[@name=$name]/@name}"/>
			<input type="hidden" name="edittextblockrepetition" value="{block/../@id}"/>
			<script language="JavaScript" type="text/javascript">
				<xsl:text disable-output-escaping="yes">&lt;!--
function submitForm() {
	//make sure hidden and iframe values are in sync before submitting form
	//to sync only 1 rte, use updateRTE(rte)
	//to sync all rtes, use updateRTEs
	updateRTE('rte1');
	//updateRTEs();
	//change the following line to true to submit form
	return true;
}

//Usage: initRTE(imagesPath, includesPath, cssFile, genXHTML, cssclass, bgcolor, presence)
initRTE("/rte/images/", "/rte/", "</xsl:text>
				<xsl:value-of select="concat(/document/production_url,'/css/style.css')"/>
				<xsl:text disable-output-escaping="yes">", true, "</xsl:text>
				<xsl:value-of select="$css"/>
				<xsl:text disable-output-escaping="yes">", "</xsl:text>
				<xsl:value-of select="$bgcolor"/>
				<xsl:text disable-output-escaping="yes">", "</xsl:text>
				<xsl:value-of select="/document/presence"/>
				<xsl:text disable-output-escaping="yes">");
//--&gt;</xsl:text>
			</script>
			<noscript>
				<p>
					<b>Javascript must be enabled to use this form.</b>
				</p>
			</noscript>
			<script language="JavaScript" type="text/javascript">
				<xsl:text disable-output-escaping="yes">&lt;!--
//Usage: writeRichText(fieldname, html, width, height, buttons, readOnly)
writeRichText('rte1', '</xsl:text>
				<xsl:value-of select="block[@name=$name]" disable-output-escaping="yes"/>
				<xsl:text disable-output-escaping="yes">', 400, 150, true, false);
//--&gt;</xsl:text>
			</script>
			<input type="submit" value="Speichern"/>
			<input type="button" value="Fenster schliessen" onclick="closewindow()"/>
		</form>
	</xsl:template>
</xsl:stylesheet><!-- Stylus Studio meta-information - (c)1998-2004. Sonic Software Corporation. All rights reserved.
<metaInformation>
<scenarios/><MapperMetaTag><MapperInfo srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/><MapperBlockPosition></MapperBlockPosition></MapperMetaTag>
</metaInformation>
-->